package com.qkjia.converter;


import org.apache.kafka.clients.consumer.ConsumerRecord;

/**
 * ConsumerRecord 到 KafkaConsumerEvent
 * @author zhaoqiankun
 * @date 2021/11/10
 */
public class ConsumerRecord2KafkaConsumerEvent {

    public static KafkaConsumerEvent convert(ConsumerRecord<Long, String> source, Object event) {
        String topic = source.topic();
        Integer partition = source.partition();
        Long key = source.key();
        String message = source.value();
        KafkaConsumerEvent target = new KafkaConsumerEvent(event, topic, key, partition, message);
        target.setRecord(source);
        return target;
    }

}
